<?php

use think\migration\Migrator;
use think\migration\db\Column;

class Notices extends Migrator
{
    /**
     * Change Method.
     *
     * Write your reversible migrations using this method.
     *
     * More information on writing migrations is available here:
     * http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
     *
     * The following commands can be used in this method and Phinx will
     * automatically reverse them when rolling back:
     *
     *    createTable
     *    renameTable
     *    addColumn
     *    renameColumn
     *    addIndex
     *    addForeignKey
     *
     * Remember to call "create()" or "update()" and NOT "save()" when working
     * with the Table class.
     */
    public function change()
    {
        $table = $this->table('notices', ['id'=>'id', 'comment'=>'消息通知表', 'engine'=>'innodb']);

        $table -> addColumn('recipients_id', 'integer', ['length'=>10, 'comment'=>'接收人id', 'default'=>0])
               -> addColumn('type', 'string', ['length'=>20, 'comment'=>'消息类型, warning:预警消息, personnel_remind:提问提醒, specialist_remind:专家回复提醒, knowledge:指导推送,', 'default'=>'warning'])
               -> addColumn('content', 'string', ['comment'=>'消息内容'])
               -> addColumn('redirect', 'string', ['comment'=>'重定向链接', 'null'=>true])
               -> addTimestamps()
               -> create();
    }
}
